<template>
	<view class="page_y1">
		<view class="title_box">
			<text class="title_t0" >信息验证</text>
		</view>
		<view class="d1_box">
			<text space="ensp" class="title_t1">|请输入您的姓名：</text>
			<input type="text" :value="username"  placeholder="在此输入姓名" class="t1_input" @blur="setusername" @confirm="setusername" />
		</view>
		<view class="d1_box">
			<text class="title_t2" >|请输入您的身份证号码：</text>
			<input type="idcard" :value="id_ka" placeholder="输入身份证号码" class="t1_input" @blur="setidka" @confirm="setidka"/>
		</view>
		<view class="d3_box">
			<button type="primary" class="chang_button" @click="yan_zhen">验证查询！</button>
			<button type="primary" class="chang_button">退出到首页</button>
		</view>
		<view class="d4_box">
			<text class="ban_quan" >@辰育网络</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username:'',
				id_ka:''
			}
		},
		methods: {
			yan_zhen(e){
				console.log("点击获取信息！");
				var me=this;
				uni.showLoading({
				    title: '获取服务器中'
				});
				
				if (me.username=='') {
					uni.hideLoading();
					uni.showToast({
						title:'姓名不能空！',
						duration:1500,
						icon:'none'
					})
				} else{
					if (me.id_ka=='') {
						uni.showToast({
							title:'身份证不能空',
							duration:1500,
							icon:'none'
						})
					} else{						
						//上传服务器看看有没有这个人
						uni.request({
							url:me.serverUrl+"/api/user/login",
							data:{
								username:me.username,
								id_ka:me.id_ka
							},
							success(res) {
								console.log(res);
								if (res.data.isok=='ok') {
											uni.redirectTo({
												url:'../cy_nianjing_y2/cy_nianjing_y2?username='+me.username+'&id_ka='+me.id_ka,
												success(e) {													
													uni.hideLoading();
												}
											});										
								} else{
									uni.showToast({
										title:'上述信息不匹配',
										duration:1500
									});
								}
							},
							fail(res) {
								console.log("服务器错误！");
								console.log(res);
								uni.showToast({
									title:'上述信息不匹配',
									duration:1500
								});
							}
						})
						
						
					}					
				}
			},
			setusername(e){
				var me=this;
				me.username=e.detail.value;
			},
			setidka(e){
				var me=this;
				me.id_ka=e.detail.value;
			}
		}
	}
</script>

<style>
@import url("cy_nianjing_y1.css");
</style>
